
cc.Class({
    extends: cc.Component,

    properties: {
        btnDiscard:{
            default:null,
            type:cc.Node,
        },
        btnFinish:{
            default:null,
            type:cc.Node
        },
        btnGroup:{
            default:null,
            type:cc.Node
        },
        btnDrop:{
            default:null,
            type:cc.Node
        }
    },


    onLoad () {
        if(!cc.gg){
            cc.gg = {}
        }
        cc.gg.optUIMgr = this

        this.btnDiscard.active = false
        this.btnFinish.active = false
        this.btnGroup.active = false
        this.btnDrop.active = false
        // this.btnDeclare.active = false
    },

    start () {

    },

    // update (dt) {},
    //
    // changeOptionState:function (state) {
    //     if(state === cc.gg.enumConfig.OptionState.DISPATCHING){
    //         this.btnDiscard.active = false
    //         this.btnFinish.active = false
    //         // this.btnGroup.active = false
    //         // this.btnDeclare.active = false
    //     }else if(state === cc.gg.enumConfig.OptionState.WAIT){
    //         this.btnDiscard.active = false
    //         this.btnFinish.active = false
    //         // this.btnGroup.active = false
    //         // this.btnDeclare.active = false
    //     }else if(state === cc.gg.enumConfig.OptionState.GRAB){
    //         this.btnDiscard.active = false
    //         this.btnFinish.active = false
    //         // this.btnGroup.active = false
    //         // this.btnDeclare.active = false
    //     }else if(state === cc.gg.enumConfig.OptionState.PLAY){
    //         // this.btnDiscard.active = true
    //         // this.btnFinish.active = true
    //         // this.btnGroup.active = false
    //         // this.btnDeclare.active = false
    //     }else if(state === cc.gg.enumConfig.OptionState.CALCULATING){
    //         this.btnDiscard.active = false
    //         this.btnFinish.active = false
    //         // this.btnGroup.active = false
    //         // this.btnDeclare.active = false
    //     }
    // },

    onOptionButtonsClicked:function (event) {
        let btnName = event.target.name
        if(btnName === "ButtonDiscard"){
            let kv = {
                keys:["function"],
                values:["button"]
            }
            let jsonStr = JSON.stringify(kv)
            cc.gg.tdUtil.doSendTdEvent("game_discard","Game",jsonStr)
            cc.find("Canvas").emit("opt_btn_discard")
        }else if(btnName === "ButtonFinish"){
            let kv = {
                keys:["function"],
                values:["button"]
            }
            let jsonStr = JSON.stringify(kv)
            cc.gg.tdUtil.doSendTdEvent("game_finish","Game",jsonStr)
            cc.find("Canvas").emit("opt_btn_finish")
        }else if(btnName === "ButtonGroup"){
            cc.gg.tdUtil.doSendTdEvent("game_group","Game")
            cc.find("Canvas").emit("opt_btn_group")
        }else if(btnName === this.btnDrop.name){
            cc.gg.tdUtil.doSendTdEvent("game_drop","Game")
            cc.find("Canvas").emit("opt_btn_drop")
        }
    }
});
